package com.evenmo.string;

import org.junit.Test;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * Math类测试
 */
public class TestMath {
    /**
     * 测试Round方法,算法是round(x)---x+0.5,得到的值在向下取整
     */
    @Test
    public void testRound(){
        System.out.println(Math.round(-1.3));
        System.out.println(Math.round(-1.5));
        System.out.println(Math.round(-1.8));
    }

    /**
     * 测试向上取整
     */
    @Test
    public void testCeil(){
        System.out.println(Math.ceil(1.4));//2.0
        System.out.println(Math.ceil(1.8));//2.0
    }

@Test
    public void testFloor(){
        System.out.println(Math.floor(1.8));//1.0
        System.out.println(Math.floor(1.2));//1.0
        System.out.println(Math.floor(-1.31));//-2.0
    }


    @Test
    public void testChu(){
        System.out.println(10 / 3);
        int x=3*5;
        int y=x+5/x+3;//15+5/15+3=15+0+3=18
        System.out.println(y);
    }

    @Test
    public void testMath(){
        int a=9;
        a=a<<5;//位移运算，等价于a=a*2^32（次方）
        System.out.println("a=" + a);
    }

    @Test
    public void test(){
        int a=15677;
        a=(a<<3);
        System.out.println(a);

        Map<String,Student> map=new HashMap<>();

        map.put("sdf",new Student(1, "sdf", 1, true));

        Set<Map.Entry<String, Student>> entries = map.entrySet();

        Iterator<Map.Entry<String, Student>> iterator = entries.iterator();
        iterator.hasNext();
        iterator.next();

        for (Map.Entry<String, Student> entry : entries) {
            entry.getKey();
            entry.getValue();
        }
    }

}
